package com.evon.yardmanagement.service;

import java.util.List;

import com.evon.yardmanagement.dao.CountryDAO;
import com.evon.yardmanagement.dao.StateDAO;
import com.evon.yardmanagement.model.Country;
import com.evon.yardmanagement.model.Oem;
import com.evon.yardmanagement.model.State;
import com.evon.yardmanagement.transformer.BaseTransformer;
import com.evon.yardmanagement.ui.dto.CountryDTO;
import com.evon.yardmanagement.ui.dto.StateDTO;

public class UtilityService implements IUtilityService {
	static CountryDAO countryDAO = new CountryDAO();
	static StateDAO stateDAO = new StateDAO();
	static BaseTransformer<Country, CountryDTO> countryTransformer = new BaseTransformer<Country, CountryDTO>(
			Country.class, CountryDTO.class);
	
	static BaseTransformer<State, StateDTO> stateTransformer = new BaseTransformer<State, StateDTO>(
			State.class, StateDTO.class);

	public boolean addOem(Oem oem) {
		// TODO Auto-generated method stub
		return false;
	}

	public List<Oem> getAllOem() {
		// TODO Auto-generated method stub
		return null;
	}

	
	public static List<CountryDTO> getCountries() {	
		List<Country> countryModelList = countryDAO.findAll();;
		return countryTransformer.transformToDTO(countryModelList);
	}

	/**
	 * Return the list of state for the given country.
	 * @param countryId
	 * @return
	 */
	public static List<StateDTO> getState(int countryId) {	
		List<State> stateModelList = stateDAO.findByProperty("country.id", countryId);
		return stateTransformer.transformToDTO(stateModelList);
	}
	
}
